package com.yanchangapp.ui.presenter;

import android.view.animation.ScaleAnimation;

import com.yanchangapp.base.HeadApiRetrofit;
import com.yanchangapp.commom.AppConstant;
import com.yanchangapp.model.bean.PassApproveBean;
import com.yanchangapp.model.response.RecordDetailResponse;
import com.yanchangapp.ui.view.ApprovePassDetailAtView;
import com.zxl.baselib.bean.response.BaseResponse;
import com.zxl.baselib.ui.base.BaseActivity;
import com.zxl.baselib.ui.base.BaseObserver;
import com.zxl.baselib.ui.base.BasePresenter;
import com.zxl.baselib.ui.base.ExceptionHandle;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by apple on 2019-08-26.
 * description: 审批详情p层
 */
public class ApprovePassDetailAtPresenter extends BasePresenter<ApprovePassDetailAtView> {

    public ApprovePassDetailAtPresenter(BaseActivity context) {
        super(context);
    }

    public void queryAvPassDetail(String orderID){
        HeadApiRetrofit.getInstance().queryAvDetailByOrderId(orderID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<PassApproveBean>>() {
                    @Override
                    public void onNext(BaseResponse<PassApproveBean> passApproveBeanBaseResponse) {
                        if ( null != getView()){
                            if (AppConstant.REQUEST_SUCCESS == passApproveBeanBaseResponse.getCode()){
                                getView().queryPassAvDetailSuccess(passApproveBeanBaseResponse.getData());
                            }else {
                                getView().queryPassAvDetailFailure(passApproveBeanBaseResponse.getMsg());
                            }
                        }
                    }

                    @Override
                    public void onError(ExceptionHandle.ResponseException exception) {
                        if (null != getView()){
                            getView().queryPassAvDetailFailure(exception.getErrorInfo());
                        }
                    }
                });
    }
}
